package com.atguigu.jxc.controller.admin;

import com.atguigu.jxc.domain.ProductVO;
import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.BasicsMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author: Leon
 * @DateTime: 2021/9/25 10:16
 */
@RestController
public class BasicsMessageController {

    @Autowired
    private BasicsMessageService basicsMessageService;

    //1、分页查询供应商
    @PostMapping("/supplier/list")
    public Map<String,Object> getList(Integer page,Integer rows, String supplierName){
        return basicsMessageService.getList(page,rows,supplierName);
    }

    //2、新增供应商/修改供应商
    @PostMapping("/supplier/save")
    public ServiceVO addSupplier(Supplier supplier){
        return basicsMessageService.addSupplier(supplier);
    }

    //3、删除供应商
    @PostMapping("/supplier/delete")
    public ServiceVO deleteSupplier(String[] ids){
        System.out.println(ids);
        return basicsMessageService.deleteSupplier(ids);
    }

    //4、客户管理-分页查询客户列表
    @PostMapping("/customer/list")
    public Map<String,Object> getCustomerList(@RequestParam("page") Integer pageNum, @RequestParam("rows") Integer pageSize, @RequestParam(value = "customerName",required = false) String  customerName){
        return basicsMessageService.getCustomerList(pageNum,pageSize,customerName);
    }

    //5、客户管理-添加/修改客户
    @PostMapping("/customer/save")
    public ServiceVO addCustomer(Customer customer){
        return basicsMessageService.addCustomer(customer);
    }

    //6、客户管理-批量删除客户
    @PostMapping("/customer/delete")
    public ServiceVO deleteCustomer(String[] ids){
        return basicsMessageService.deleteCustomer(ids);
    }

    //7、商品管理-树形目录
    @PostMapping("/goodsType/loadGoodsType")
    public List<ProductVO> getProductTree(){
        return basicsMessageService.getProductTree();
    }

    //8、商品管理-查询所有商品单位
    @PostMapping("/unit/list")
    public Map<String,Object> getAllUnit(){
        return basicsMessageService.getAllUnit();
    }

    //9、商品管理-根据商品类型id和模糊查询获取商品列表
    @PostMapping("/goods/list")
    public Map<String,Object> getGoodsList(@RequestParam("page") Integer pageNum,
                                           @RequestParam("rows") Integer pageSize,
                                           @RequestParam(value = "goodsName",required = false)String goodsName,
                                           @RequestParam(value = "goodsTypeId",required = false) Integer goodsTypeId){
       return basicsMessageService.getGoodsList(pageNum,pageSize,goodsName,goodsTypeId);
    }

    //10、商品管理-新增分类
    @PostMapping("/goodsType/save")
    public ServiceVO addGoodType(String goodsTypeName,Integer pId){
        return basicsMessageService.addGoodType(goodsTypeName,pId);
    }

    //11、商品管理-删除分类
    @PostMapping("/goodsType/delete")
    public ServiceVO deleteGoodType(Integer goodsTypeId){
        return basicsMessageService.deleteGoodType(goodsTypeId);
    }

    //14、根据商品名称或编码查询无库存商品列表
    @PostMapping("/goods/getNoInventoryQuantity")
    public Map<String,Object> getNoInventoryQuantity(@RequestParam("page") Integer pageNo,@RequestParam("rows") Integer pageSize,String nameOrCode){
        return basicsMessageService.getNoInventoryQuantity(pageNo,pageSize,nameOrCode);
    }

    //15、根据商品名称或编码查询有库存商品列表
    @PostMapping("/goods/getHasInventoryQuantity")
    public Map<String,Object> getHasInventoryQuantity(@RequestParam("page") Integer pageNo,@RequestParam("rows") Integer pageSize,String nameOrCode){
        return basicsMessageService.getHasInventoryQuantity(pageNo,pageSize,nameOrCode);
    }

}
